<extend name="Public:innerbase" />
<block name="js">
<include file="Public:upload" />
<include file="Public:editor" />
<script type="text/javascript">
var TPL='<span class="label label-default label-spec"><input type="hidden" name="spec[]" value="%s"/>%s&nbsp;<div class="spec-remove text-danger"><i class="fa fa-times"></i></div></span>';
$('.label-spec .spec-remove').click(function(){
	$(this).parents('.label-spec').remove();
});
$('#commitSpec').click(function(){
	var spec = $('#specAdd').val();
	if(spec){
		var specEl = $(sprintf(TPL,spec,spec));
		specEl.find('.spec-remove').click(function(){
			$(this).parents('.label-spec').remove();
		});
		specEl.insertBefore($('#btnSpecAdd'));
		$('#specDialog').modal('hide');
		$('#specAdd').val('');
	}
});
</script>
</block>
<block name="css">
<style>
.label-spec{
position:relative;
margin-right:15px;
}
.spec-remove{
position:absolute;
top:-4px;
right:-4px;
display:none;
cursor:pointer;
}
.label-spec:hover .spec-remove{
display:block;
}
</style>
</block>
<block name="content">
<div class="container-fluid">
	<div class="page-header wm-page-header">
		<h4>产品设置</h4>
		<a href="{:U('index')}" class="btn btn-default btn-sm">
			<span class="glyphicon glyphicon-chevron-left"></span>&nbsp;返回
		</a>
	</div>
	<form class="form-horizontal" method="post">
		<input type="hidden" name="id" value="{$set.id}" />
		<div class="form-group">
			<label class="col-sm-2">名称</label>
			<div class="col-md-4">
				<input type="text" name="name" value="{$set.name}" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">分类</label>
			<div class="col-md-2">
				<select id="cate_id" name="cate_id" class="form-control">
					<option value="0">请选择分类...</option>
					<volist name="cates" id="vo">
					<option value="{$vo.id}" <if condition="$set['cate_id'] eq $vo['id']">selected</if>>{$vo.cate_name}</option>
					</volist>
				</select>
			</div>
		</div>
		<div class="form-group" style="display:none;">
			<label class="col-sm-2">场地</label>
			<div class="col-md-4">
				<input type="text" name="storeid" value="{$set.name}" class="form-control" />
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">促销价</label>
			<div class="col-md-2">
				<div class="input-group">
					<input type="text" id="price" name="price" value="{$set.price}" class="form-control" />
					<span class="input-group-addon">元</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">原价</label>
			<div class="col-md-2">
				<div class="input-group">
					<input type="text" id="oprice" onchange="calDiscount();" name="oprice" value="{$set.oprice}" class="form-control" />
					<span class="input-group-addon">元</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">星级</label>
			<div class="col-md-2">
				<input type="text" name="stars" value="{$set.stars}" class="form-control" />
				<span class="help-block">值范围为1-5</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">规格</label>
			<div class="col-md-10">
				<volist name="specs" id="vo">
				<span class="label label-default label-spec">
				<input type="hidden" name="spec[]" value="{$vo}"/>
				{$vo}&nbsp;<div class="spec-remove text-danger"><i class="fa fa-times"></i></div>
				</span>
				</volist>
				<span id="btnSpecAdd" class="btn btn-xs btn-primary" data-toggle="modal" data-target="#specDialog"><i class="fa fa-plus"></i>&nbsp;添加</span>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">产品图片</label>
			<div class="col-sm-6">
				<input type="hidden" class="form-control" value="{$set.img}" id="img" name="img" />
				<img id="imgHolder" style="width:216px;height:120px;" <if condition="$set['img'] eq ''">src="{:RES}/images/photo/noneimg.jpg"</if> src="{$set.img}"/>
				<div class="btn-group" style="vertical-align:bottom;">
					<span class="btn btn-xs btn-primary" onclick="selectAsset('img',720,400)">
						<span class="glyphicon glyphicon-cloud-upload"></span>选择
					</span>
					<span class="btn btn-primary btn-xs" onclick="previewImg('img')">
						<span class="glyphicon glyphicon-picture"></span>预览
					</span>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-2">详细介绍</label>
			<div class="col-md-6">
				<textarea class="form-control" name="intro" id="content" rows="5" style="height:260px">{$set.intro}</textarea>
			</div>
		</div>
		<div class="form-group">
			<div class="col-md-5 col-sm-offset-2">
				<input type="submit" class="btn btn-primary" value="保存" />
			</div>
		</div>
	</form>
</div>
<div class="modal fade" id="specDialog">
	<div class="modal-dialog modal-sm">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				<h4 class="modal-title">添加规格</h4>
			</div>
			<div class="modal-body">
				<input name="spec" id="specAdd" type="text" class="form-control"/>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" id="commitSpec" class="btn btn-primary">确定</button>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</block>